﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Compilation;
using System.Web.UI;
using System.Text.RegularExpressions;
using System.Web.Routing;

namespace Presentation.Web.UI.Helpers
{
    public static class ResourceHelper
    {
        public static string ResourceText(this HtmlHelper htmlHelper, int resourceKey)
        {
            return htmlHelper.GetResource(resourceKey.ToString());
        }
        public static string ResourceClassAndText(this HtmlHelper htmlHelper, string classKey, int resourceKey)
        {
            return htmlHelper.GetResource(classKey, resourceKey.ToString());
        }

        private static string GetResource(this HtmlHelper htmlHelper, string resourceKey)
        {
            if (String.IsNullOrEmpty(resourceKey))
            {
                throw new ArgumentException("Invalid resourceKey.", "resourceKey");
            }
            return htmlHelper.ViewContext.HttpContext.GetGlobalResourceObject("_text_", resourceKey) as string;
        }
        private static string GetResource(this HtmlHelper htmlHelper, string classKey, string resourceKey)
        {
            if (String.IsNullOrEmpty(resourceKey))
            {
                throw new ArgumentException("Invalid resourceKey.", "resourceKey");
            }
            return htmlHelper.ViewContext.HttpContext.GetGlobalResourceObject(classKey, resourceKey) as string;
        }
    }
}
